<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 * 包保单位or采集单位
 */
class GatherCompany extends AppModel
{
    //

    const IS_TYPE_ONE = 1; //包保单位
    const IS_TYPE_TWO = 2; //责任单位


    public function admin(){
        return $this->hasMany(Admins::class,'unit_id')->field('id,username,mobile,unit_id');
    }

    public function community(){
        return $this->hasOne(Community::class,'id');
    }

    //总数
    public function collect(){
        return $this->hasMany(Collect::class,'gather_company_id');
    }

    //未审核
    public function status(){
        return $this->hasMany(Collect::class,'gather_company_id');
    }

    //无效案件
    public function invalid(){
        return $this->hasMany(Collect::class,'gather_company_id');
    }

    //整改
    public function recti(){
        return $this->hasMany(Collect::class,'gather_company_id')->field('id,gather_company_id,uid');
    }

    //志愿服务
    public function voluntary(){
        return $this->hasMany(Voluntary::class,'unit_id')->field('id,unit_id');
    }

    //志愿服务未审核
    public function vsatus(){
        return $this->hasMany(Voluntary::class,'unit_id')->field('id,unit_id');
    }
    //志愿服务合格
    public function HGV(){
        return $this->hasMany(Voluntary::class,'unit_id')->field('id,unit_id');
    }

    //志愿服务不合格
    public function notHg(){
        return $this->hasMany(Voluntary::class,'unit_id')->field('id,unit_id');
    }


    //月报表
    public function monthReport(){
        return $this->hasMany(MonthReport::class,'unit_id')->field('id,unit_id');
    }
    //月报表未审核
    public function msatus(){
        return $this->hasMany(MonthReport::class,'unit_id')->field('id,unit_id');
    }
    //月报表合格
    public function HGM(){
        return $this->hasMany(MonthReport::class,'unit_id')->field('id,unit_id');
    }

    //月报表不合格
    public function notHgmr(){
        return $this->hasMany(MonthReport::class,'unit_id')->field('id,unit_id');
    }

    //整改
    public function rectification(){
        return $this->hasMany(Rectification::class,'unit_id')->field('id,unit_id');
    }
    //有效整改
    public function yxZG(){
        return $this->hasMany(Rectification::class,'unit_id')->field('id,unit_id');
    }
    //无效整改
    public function wxZG(){
        return $this->hasMany(Rectification::class,'unit_id')->field('id,unit_id');
    }
    //未整改
    public function wZg(){
        return $this->hasMany(Rectification::class,'unit_id')->field('id,unit_id');
    }

    //领导调度
    public function leader(){
        return $this->hasMany(LeaderDoc::class,'unit_id')->where(['draft'=>2]);
    }
    //实地考察
    public function sceneInspect(){
        return $this->hasMany(InspectActivity::class,'unit_id')->where(['draft'=>2,'module'=>1]);
    }
    //申报活动
    public function declareActivity(){

        return $this->hasMany(InspectActivity::class,'unit_id')->where(['draft'=>2,'module'=>2]);
    }

    //实践活动
    public function practiceActivity(){
        return $this->hasMany(InspectActivity::class,'unit_id')->where(['draft'=>2,'module'=>3]);
    }

    //宣传劝导
    public function examine(){
        return $this->hasMany(Examine::class,'unit_id')->where(['draft'=>2]);
    }

    //特色工作
    public function characteristic(){
        return $this->hasMany(Characteristic::class,'unit_id')->where(['draft'=>2]);
    }

    //疑难问题
    public function difficult(){
        return $this->hasMany(Difficult::class,'unit_id')->where(['draft'=>2]);
    }

    //测评考核
    public function assess(){
        return $this->hasOne(Assess::class,'unit_id');
    }
}
